from kivy.uix.floatlayout import FloatLayout

from amgineirc.view.channels.logView import LogView
from amgineirc.view.messageView import MessageView
from amgineirc.view.channels.sendView import SendView
from amgineirc.viewModel.channels.channelViewModel import ChannelViewModel


"""
left-top = log view
right-top = users view
bottom = send view
"""
class ChannelView(FloatLayout, MessageView):
    def __init__(self, connection, target, appdata):
        FloatLayout.__init__(self, size_hint=(1.0, 1.0))
        MessageView.__init__(self)
        self.target = target
        # the recieve view - top left
        self.receive_view = LogView(size_hint=(1.0, 0.9),
                                    pos_hint={'x':0.0, 'y':0.1},
                                    maximum_log_count=50)
        self.add_widget(self.receive_view)
        # the send view - bottom
        self.send_view = SendView(size_hint=(1.0, 0.1),
                                  pos_hint={'x':0.0, 'y':0.0})
        self.add_widget(self.send_view)
        # initialize the view model
        self.view_model = ChannelViewModel(self,
                                           self.send_view,
                                           self.receive_view,
                                           connection,
                                           target,
                                           appdata)

    # view model methods for wrapper view not this view

    def vm_set_state(self, **kargs):
        if 'connected' in kargs:
            # ignore
            pass
